//
// Created by LiuYou on 2020/8/7.
//

#ifndef CHAPTER02_CPU_H
#define CHAPTER02_CPU_H


#include <ostream>
#include "Object.h"

namespace ly {
    class Cpu : public Object {
    private:
        int speed;
    public:
        int getSpeed() const {
            return speed;
        }

        void setSpeed(int speed) {
            Cpu::speed = speed;
        }

        std::string toString() const override {
            return Object::toString() +
                   "Cpu{speed=" + std::to_string(speed) +
                   "}";
        }


//        std::string toString() const override {
//            return Object::toString() +
//                   (std::string) "Cpu{" +
//                   "speed=" + std::to_string(speed) +
//                   '}';
//        }

        friend std::ostream& operator<<(std::ostream& os, const Cpu& cpu) {
            os << static_cast<const Object&>(cpu) << " speed: " << cpu.speed;
            return os;
        }

        ~Cpu() override = default;

        explicit Cpu(int speed = 10000) : speed(speed) {}

    };

//    extern Cpu cpu;
}


#endif //CHAPTER02_CPU_H
